﻿using System;
using ConceptsFramework.AbstractConceptElements;
using ConceptsFramework.Containers.Generic;
using ConceptsFramework.DerivedRelationships;

namespace PatternExplorer.DerivedConcepts
{
    public class TypeSummary : AbstractBindableConcept, IEquatable<TypeSummary>
    {
        public BindableConceptContainer<MethodSummary> PublicMethods;
        public BindableConceptContainer<MethodSummary> PrivateMethods;
        public BindableConceptContainer<PropertySummary> PublicProperties;
        public BindableConceptContainer<PropertySummary> PrivateProperties;
        //ajt
        public BindableConceptContainer<FieldSummary> PublicFields;
        public BindableConceptContainer<FieldSummary> PrivateFields;

        public TypeSummary()
        {
            PublicMethods = new BindableConceptContainer<MethodSummary>();
            // Defines the concept key
            PublicMethods.ConceptKeyRetriever = (a => a.Name);
            PublicMethods.ParentConcept = this;

            PrivateMethods = new BindableConceptContainer<MethodSummary>();
            // Defines the concept key
            PrivateMethods.ConceptKeyRetriever = (a => a.Name);
            PrivateMethods.ParentConcept = this;

            PublicProperties = new BindableConceptContainer<PropertySummary>();
            // Defines the concept key
            PublicProperties.ConceptKeyRetriever = (a => a.Name);
            PublicProperties.ParentConcept = this;

            PrivateProperties = new BindableConceptContainer<PropertySummary>();
            // Defines the concept key
            PrivateProperties.ConceptKeyRetriever = (a => a.Name);
            PrivateProperties.ParentConcept = this;
        }

        public bool IsAbstract { get; set; }
        public bool IsInterface { get; set; }
        public bool IsStatic { get; set; }

        public override bool IsRelationshipAutorized<T>()
        {
            Type paramType = typeof(T);
            if (typeof(HostRelationship).IsAssignableFrom(paramType))
                return true;
            if (typeof(IsContainedRelationship).IsAssignableFrom(paramType))
                return true;
            return false;
        }

        public override void ResolveInverseRelationships()
        {

        }


        public bool Equals(TypeSummary other)
        {
            return (this.Name == other.Name);
        }

    }
}
